package com.example.application.views.util;

import com.vaadin.flow.component.Text;
import com.vaadin.flow.component.UI;
import com.vaadin.flow.component.button.Button;
import com.vaadin.flow.component.dialog.Dialog;
import com.vaadin.flow.component.html.Div;

public class DialogUtil {
    public static void adminAuthority(){
        Dialog dialog = new Dialog();
        dialog.setCloseOnEsc(false);
        dialog.setCloseOnOutsideClick(false);
        dialog.removeAll();
        dialog.add(new Text("权限不够"));
        dialog.add(new Div(new Button("去切换账号", e->{
            dialog.close();
            UI.getCurrent().navigate("login");
        })));
        dialog.open();
    }

    public static void deleteDialog(){

        Dialog dialog = new Dialog();
        dialog.setCloseOnEsc(false);
        dialog.setCloseOnOutsideClick(false);
        dialog.removeAll();
        dialog.add(new Text("确定要删除吗？"));

        Button okBtn = new Button("确定", sure ->{
//            执行删除操作

            dialog.close();
        });

        Button noBtn = new Button("取消",e2->{
            dialog.close();
        });

        dialog.add(new Div(okBtn, new Text("      "), noBtn));
        dialog.open();

    }

}
